-- Woot for steaming pile of bullshit! It's still better than sending to all players - right?
if SERVER then

	hook.Add("PlayerInitialSpawn", "RetrieveGlobalNeWVars", function(pl)
		pl.NeWVars = {}
		pl.NeWVars["Bool"] = {}
		pl.NeWVars["Int"] = {}
	
		if file.Exists("lusion/player_data/"..string.gsub(string.lower(pl:SteamID()), ":", "_")..".txt") then
			for k,v in pairs(util.KeyValuesToTable(file.Read("lusion/player_data/"..string.gsub(string.lower(pl:SteamID()), ":", "_")..".txt"))["NeWVars"]["Bool"]) do
				if k and v then
					pl:SetNeWBool( k, v, true )
				end
			end
			-- Not done. :(
			--for k,v in pairs(util.KeyValuesToTable(file.Read("lusion/player_data/"..string.gsub(string.lower(pl:SteamID()), ":", "_").."txt"))["NeWVars"]["String"]) do
				---pl:SetNeWString( k, v, true )
			--end
		end
	end)

	function _R.Player:SetNeWBool( String_Key, Bool_Value, Bool_IsSaved )
		if not ( String_Key or Bool_Value ) then return end
		if not ( Bool_IsSaved ) then Bool_IsSaved = false end
		self.NeWVars["Bool"][String_Key] = tobool(Bool_Value)
		umsg.Start("SendNeWVars_Bool", self)
			umsg.String(String_Key)
			umsg.Bool(Bool_Value)
		umsg.End()
		
		if Bool_IsSaved == true then
			file.Append(util.KeyValuesToTable("lusion/player_data/"..string.gsub(string.lower(pl:SteamID(), ":", "_"))..".txt")["NeWVars"]["Bool"], {key = String_Key, value = Bool_Value})
		end
	end
	function _R.Player:GetNeWBool( String_Key )
		if not ( String_Key ) then return end
		return self.NeWVars["Bool"][String_Key] or nil
	end
	
elseif CLIENT then
	usermessage.Hook("SendNeWVars_Bool", function( um )
		LocalPlayer().NeWVars = LocalPlayer().NeWVars or {}
		LocalPlayer().NeWVars["Bool"] = LocalPlayer().NeWVars["Bool"] or {}
		
		LocalPlayer().NeWVars["Bool"][um:ReadString()] = um:ReadBool()
	end)
	function _R.Player:GetNeWBool( String_Key )
		if not ( String_Key ) then return end
		return self.NeWVars["Bool"][String_Key] or nil
	end
end
	
	
	
	
	
	